﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ZY
{
    class Program
    {
        static void Main(string[] args)
        {
            text1();
            text2();
            text3();
            text4();
        }
        public static void text1()
        {
            string S = "ddsdd 12 , 3 ,  5";
            int digicount = 0;
            int IsLetter = 0;
            int c = 0;
            foreach (char item in S)
            {
                if (char.IsDigit(item))//数字
                {
                    digicount++;
                }
                else if (char.IsLetter(item))//字母
                {
                    IsLetter++;
                }
                else if (char.IsWhiteSpace(item))
                {
                    c++;
                }

            }
            Console.WriteLine("数字个数：" + digicount + "字母个数：" + IsLetter + "空格个数" + c);
        }



        public static void text2()
        {
            //在 Main 方法中创建一个 double 类型的数组，
            //在该数组中存入 5 名学生的考试成绩(控制台输入)，计算总成绩和平均成绩。
            //要求使用foreach语句实现该功能，
            double[] arr = new double[5];
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                Console.WriteLine("请输入" + (i + 1) + "个数字");
                arr[i] = double.Parse(Console.ReadLine());
            }
            foreach (var item in arr)
            {
                Console.WriteLine("总成绩" + (arr[0] + arr[1] + arr[2] + arr[3]));
                Console.WriteLine("平均成绩" + ((arr[0] + arr[1] + arr[2] + arr[3]) / 5));
                break;

            }
        }


        public static void text3()
        {
            int[] arr = { 30, 45, 20, 10 };
            Console.WriteLine("排序前");
            for (int i = 0; i < arr.Length; i++)
            {
                Console.WriteLine(arr[i] + " ");

            }
            Array.Sort(arr);//小到大
            Array.Reverse(arr);//大到小
            Console.WriteLine();



            Console.WriteLine("排序后");
            for (int i = 0; i < arr.Length; i++)
            {
                Console.WriteLine(arr[i] + " ");

            }
            Console.WriteLine();
        }
    
        public static void text4()
        {
            for (int i = 1; i < 10; i++) 
            {
                for (int j = 1; j < 10; j++)
                {
                    if (j<=i)
                    {
                        Console.Write("{0}*{1}={2}\t",i,j,i*j );
                    }
                }
                Console.WriteLine();
            }
            Console.ReadKey();
            }
        
    }
}


     
            


        
    


